<?php
/**
 * 分类模型
 */

namespace app\common\model;

use think\model\concern\SoftDelete;

class Type extends CommonBaseModel {
	use SoftDelete;
	// 自定义选择数据

	const STATUS_LIST = [
		0 => '禁用',
		1 => '启用',
	];
	protected $name = 'type';
	protected $autoWriteTimestamp = true;

	// 可搜索字段
	public array $searchField = ['name'];

	// 可作为条件的字段
	public array $whereField = ['tag'];

	// 可作为多选条件的字段
	public array $multiWhereField = [];

	// 可做为时间
	public array $timeField = [];

	public function getStatusNameAttr($value, $data) {
		return self::STATUS_LIST[$data['status']];
	}
	/**
	 * 关联
	 */
	public function typeLog() {
		return $this->hasMany(TypeLog::class);
	}/**
	 * 关联
	 */
	public function parent() {
		return $this->belongsTo(Parent::class);
	}
	public function spec() {
		return $this->belongsTo(Spec::class);
	}
	public function brand() {
		return $this->belongsTo(Brand::class);
	}

}
